home *** CD-ROM | disk | FTP | other *** search
open in:
MacOS 8.1
|
Win98
|
DOS
browse contents |
view JSON data
|
view as text
This file was processed as: Mailbox/MIME Entity
(archive/mbox).
Confidence | Program | Detection | Match Type | Support
|
---|
100%
| dexvert
| Mailbox/MIME Entity (archive/mbox)
| magic
| Supported |
1%
| dexvert
| Text File (text/txt)
| fallback
| Supported |
100%
| file
| C++ source text
| default
| |
99%
| file
| C source text
| default
| |
98%
| file
| C source, ASCII text
| default
| |
100%
| checkBytes
| Printable ASCII
| default
| |
100%
| perlTextCheck
| Likely Text (Perl)
| default
| |
100%
| siegfried
| fmt/950 MIME Email (1.0)
| default
| |
100%
| detectItEasy
| Format: plain text[LF]
| default (weak)
|
|
hex view+--------+-------------------------+-------------------------+--------+--------+
|00000000| 4e 65 77 73 67 72 6f 75 | 70 73 3a 20 63 6f 6d 70 |Newsgrou|ps: comp|
|00000010| 2e 6c 61 6e 67 2e 63 2b | 2b 0a 50 61 74 68 3a 20 |.lang.c+|+.Path: |
|00000020| 69 6e 32 2e 75 75 2e 6e | 65 74 21 62 63 73 74 65 |in2.uu.n|et!bcste|
|00000030| 63 21 6e 6e 74 70 0a 46 | 72 6f 6d 3a 20 4b 65 76 |c!nntp.F|rom: Kev|
|00000040| 69 6e 20 49 6e 67 61 6c | 6c 73 20 3c 69 6e 67 6b |in Ingal|ls <ingk|
|00000050| 6c 39 30 30 40 63 63 6d | 61 69 6c 2e 63 61 2e 62 |l900@ccm|ail.ca.b|
|00000060| 6f 65 69 6e 67 2e 63 6f | 6d 3e 0a 53 75 62 6a 65 |oeing.co|m>.Subje|
|00000070| 63 74 3a 20 52 65 3a 20 | 4f 76 65 72 6c 6f 61 64 |ct: Re: |Overload|
|00000080| 65 64 20 56 69 72 74 75 | 61 6c 20 66 75 6e 63 74 |ed Virtu|al funct|
|00000090| 69 6f 6e 73 0a 58 2d 4e | 6e 74 70 2d 50 6f 73 74 |ions.X-N|ntp-Post|
|000000a0| 69 6e 67 2d 48 6f 73 74 | 3a 20 31 33 37 2e 31 33 |ing-Host|: 137.13|
|000000b0| 36 2e 31 36 2e 31 34 39 | 0a 43 6f 6e 74 65 6e 74 |6.16.149|.Content|
|000000c0| 2d 54 79 70 65 3a 20 74 | 65 78 74 2f 70 6c 61 69 |-Type: t|ext/plai|
|000000d0| 6e 3b 20 63 68 61 72 73 | 65 74 3d 75 73 2d 61 73 |n; chars|et=us-as|
|000000e0| 63 69 69 0a 4d 65 73 73 | 61 67 65 2d 49 44 3a 20 |cii.Mess|age-ID: |
|000000f0| 3c 44 6e 47 47 77 4b 2e | 32 44 77 40 62 63 73 74 |<DnGGwK.|2Dw@bcst|
|00000100| 65 63 2e 63 61 2e 62 6f | 65 69 6e 67 2e 63 6f 6d |ec.ca.bo|eing.com|
|00000110| 3e 0a 54 6f 3a 20 73 6f | 6e 69 61 5f 6d 61 6e 67 |>.To: so|nia_mang|
|00000120| 61 74 40 62 64 73 69 2e | 63 6f 6d 0a 53 65 6e 64 |at@bdsi.|com.Send|
|00000130| 65 72 3a 20 6e 6e 74 70 | 40 62 63 73 74 65 63 2e |er: nntp|@bcstec.|
|00000140| 63 61 2e 62 6f 65 69 6e | 67 2e 63 6f 6d 20 28 4e |ca.boein|g.com (N|
|00000150| 4e 54 50 20 4e 65 77 73 | 20 41 63 63 65 73 73 29 |NTP News| Access)|
|00000160| 0a 43 6f 6e 74 65 6e 74 | 2d 54 72 61 6e 73 66 65 |.Content|-Transfe|
|00000170| 72 2d 45 6e 63 6f 64 69 | 6e 67 3a 20 37 62 69 74 |r-Encodi|ng: 7bit|
|00000180| 0a 4f 72 67 61 6e 69 7a | 61 74 69 6f 6e 3a 20 42 |.Organiz|ation: B|
|00000190| 6f 65 69 6e 67 20 44 65 | 66 65 6e 73 65 20 26 20 |oeing De|fense & |
|000001a0| 53 70 61 63 65 20 47 72 | 6f 75 70 20 54 72 61 69 |Space Gr|oup Trai|
|000001b0| 6e 69 6e 67 0a 52 65 66 | 65 72 65 6e 63 65 73 3a |ning.Ref|erences:|
|000001c0| 20 3c 34 67 76 38 74 6f | 24 37 64 6d 40 6e 65 77 | <4gv8to|$7dm@new|
|000001d0| 73 2e 62 64 73 69 2e 63 | 6f 6d 3e 0a 4d 69 6d 65 |s.bdsi.c|om>.Mime|
|000001e0| 2d 56 65 72 73 69 6f 6e | 3a 20 31 2e 30 0a 44 61 |-Version|: 1.0.Da|
|000001f0| 74 65 3a 20 54 75 65 2c | 20 32 37 20 46 65 62 20 |te: Tue,| 27 Feb |
|00000200| 31 39 39 36 20 32 32 3a | 32 34 3a 32 30 20 47 4d |1996 22:|24:20 GM|
|00000210| 54 0a 58 2d 4d 61 69 6c | 65 72 3a 20 4d 6f 7a 69 |T.X-Mail|er: Mozi|
|00000220| 6c 6c 61 20 31 2e 31 4e | 20 28 4d 61 63 69 6e 74 |lla 1.1N| (Macint|
|00000230| 6f 73 68 3b 20 49 3b 20 | 50 50 43 29 0a 58 2d 55 |osh; I; |PPC).X-U|
|00000240| 72 6c 3a 20 6e 65 77 73 | 3a 34 67 76 38 74 6f 24 |rl: news|:4gv8to$|
|00000250| 37 64 6d 40 6e 65 77 73 | 2e 62 64 73 69 2e 63 6f |7dm@news|.bdsi.co|
|00000260| 6d 0a 0a 73 6f 6e 69 61 | 5f 6d 61 6e 67 61 74 40 |m..sonia|_mangat@|
|00000270| 62 64 73 69 2e 63 6f 6d | 20 28 53 6f 6e 69 61 20 |bdsi.com| (Sonia |
|00000280| 4d 61 6e 67 61 74 29 20 | 77 72 6f 74 65 3a 0a 3e |Mangat) |wrote:.>|
|00000290| 48 69 20 65 76 65 72 79 | 62 6f 64 79 2c 0a 3e 49 |Hi every|body,.>I|
|000002a0| 20 68 61 76 65 20 61 20 | 71 75 65 73 74 69 6f 6e | have a |question|
|000002b0| 20 6f 6e 20 6f 76 65 72 | 6c 6f 61 64 65 64 20 76 | on over|loaded v|
|000002c0| 69 72 74 75 61 6c 20 66 | 75 6e 63 74 69 6f 6e 73 |irtual f|unctions|
|000002d0| 2e 20 49 20 68 61 76 65 | 20 69 6e 63 6c 75 64 65 |. I have| include|
|000002e0| 64 20 61 0a 3e 70 72 6f | 67 72 61 6d 20 74 68 61 |d a.>pro|gram tha|
|000002f0| 74 20 68 61 73 20 61 20 | 70 61 72 65 6e 74 20 63 |t has a |parent c|
|00000300| 6c 61 73 73 20 77 69 74 | 68 20 6f 76 65 72 6c 6f |lass wit|h overlo|
|00000310| 61 64 65 64 20 76 69 72 | 74 75 61 6c 20 66 75 6e |aded vir|tual fun|
|00000320| 63 74 69 6f 6e 73 2e 0a | 3e 49 20 68 61 76 65 20 |ctions..|>I have |
|00000330| 61 6c 73 6f 20 61 74 74 | 61 63 68 65 64 20 74 68 |also att|ached th|
|00000340| 65 20 63 6f 6d 70 69 6c | 61 74 69 6f 6e 20 65 72 |e compil|ation er|
|00000350| 72 6f 72 20 49 20 67 65 | 74 2e 0a 3e 0a 3e 54 68 |ror I ge|t..>.>Th|
|00000360| 65 20 77 61 79 73 20 49 | 20 63 61 6e 20 74 68 69 |e ways I| can thi|
|00000370| 6e 6b 20 6f 66 20 63 6f | 72 72 65 63 74 69 6e 67 |nk of co|rrecting|
|00000380| 20 74 68 69 73 20 70 72 | 6f 62 6c 65 6d 20 61 72 | this pr|oblem ar|
|00000390| 65 0a 3e 20 2d 2d 3e 20 | 44 65 63 6c 61 72 65 20 |e.> --> |Declare |
|000003a0| 74 68 65 20 6f 74 68 65 | 72 20 70 72 6f 74 6f 74 |the othe|r protot|
|000003b0| 79 70 65 20 69 6e 20 74 | 68 65 20 63 6c 61 73 73 |ype in t|he class|
|000003c0| 20 42 20 61 6e 64 20 6d | 61 6b 65 20 69 74 20 63 | B and m|ake it c|
|000003d0| 61 6c 6c 20 69 74 27 73 | 0a 3e 20 20 20 20 20 70 |all it's|.> p|
|000003e0| 61 72 65 6e 74 27 73 20 | 66 75 6e 63 74 69 6f 6e |arent's |function|
|000003f0| 2e 0a 3e 20 2d 2d 3e 20 | 47 69 76 65 20 64 69 66 |..> --> |Give dif|
|00000400| 66 65 72 65 6e 74 20 6e | 61 6d 65 73 20 66 6f 72 |ferent n|ames for|
|00000410| 20 74 68 65 20 76 69 72 | 74 75 61 6c 20 66 75 6e | the vir|tual fun|
|00000420| 63 74 69 6f 6e 2e 0a 3e | 0a 3e 20 49 20 64 6f 6e |ction..>|.> I don|
|00000430| 27 74 20 6c 69 6b 65 20 | 62 6f 74 68 20 74 68 65 |'t like |both the|
|00000440| 73 65 20 6f 70 74 69 6f | 6e 73 2e 20 49 73 20 74 |se optio|ns. Is t|
|00000450| 68 65 72 65 20 61 6e 79 | 20 6f 74 68 65 72 20 77 |here any| other w|
|00000460| 61 79 20 74 6f 20 73 6f | 6c 76 65 20 74 68 69 73 |ay to so|lve this|
|00000470| 20 0a 0a 3e 70 72 6f 62 | 6c 65 6d 3f 0a 3e 0a 3e | ..>prob|lem?.>.>|
|00000480| 50 6c 65 61 73 65 20 72 | 65 73 70 6f 6e 64 20 74 |Please r|espond t|
|00000490| 6f 20 3a 20 76 69 64 68 | 79 61 40 62 64 73 69 2e |o : vidh|ya@bdsi.|
|000004a0| 63 6f 6d 0a 3e 0a 3e 54 | 68 61 6e 6b 73 20 69 6e |com.>.>T|hanks in|
|000004b0| 20 61 64 76 61 6e 63 65 | 0a 3e 76 69 64 68 79 61 | advance|.>vidhya|
|000004c0| 0a 0a 49 20 74 68 69 6e | 6b 20 74 68 61 74 20 79 |..I thin|k that y|
|000004d0| 6f 75 20 68 61 76 65 20 | 62 65 65 6e 20 6d 69 73 |ou have |been mis|
|000004e0| 6c 65 64 20 61 62 6f 75 | 74 20 76 69 72 74 75 61 |led abou|t virtua|
|000004f0| 6c 20 66 75 6e 63 74 69 | 6f 6e 73 2e 20 49 6e 20 |l functi|ons. In |
|00000500| 6f 72 64 65 72 20 74 6f | 20 6d 61 6b 65 0a 75 73 |order to| make.us|
|00000510| 65 20 6f 66 20 76 69 72 | 74 75 61 6c 20 66 75 6e |e of vir|tual fun|
|00000520| 63 74 69 6f 6e 73 2c 20 | 79 6f 75 20 6e 65 65 64 |ctions, |you need|
|00000530| 20 70 6f 69 6e 74 65 72 | 73 20 74 6f 20 62 61 73 | pointer|s to bas|
|00000540| 65 20 63 6c 61 73 73 65 | 73 2e 20 54 68 65 20 76 |e classe|s. The v|
|00000550| 69 72 74 75 61 6c 20 66 | 75 6e 63 74 69 6f 6e 0a |irtual f|unction.|
|00000560| 6d 65 63 68 61 6e 69 73 | 6d 20 64 6f 65 73 20 6e |mechanis|m does n|
|00000570| 6f 74 20 77 6f 72 6b 20 | 69 66 20 79 6f 75 20 75 |ot work |if you u|
|00000580| 73 65 20 6f 62 6a 65 63 | 74 73 20 64 69 72 65 63 |se objec|ts direc|
|00000590| 74 6c 79 2e 20 49 20 68 | 61 76 65 20 72 65 77 6f |tly. I h|ave rewo|
|000005a0| 72 6b 65 64 20 79 6f 75 | 72 20 63 6f 64 65 0a 65 |rked you|r code.e|
|000005b0| 78 61 6d 70 6c 65 20 74 | 6f 20 6d 61 6b 65 20 75 |xample t|o make u|
|000005c0| 73 65 20 6f 66 20 76 69 | 72 74 75 61 6c 20 66 75 |se of vi|rtual fu|
|000005d0| 6e 63 74 69 6f 6e 73 2e | 20 49 20 68 6f 70 65 20 |nctions.| I hope |
|000005e0| 74 68 61 74 20 74 68 69 | 73 20 68 65 6c 70 73 2e |that thi|s helps.|
|000005f0| 20 4c 65 74 20 6d 65 20 | 6b 6e 6f 77 0a 69 66 20 | Let me |know.if |
|00000600| 79 6f 75 20 6e 65 65 64 | 20 63 6c 61 72 69 66 69 |you need| clarifi|
|00000610| 63 61 74 69 6f 6e 2e 0a | 0a 23 69 6e 63 6c 75 64 |cation..|.#includ|
|00000620| 65 20 3c 69 6f 73 74 72 | 65 61 6d 2e 68 3e 0a 0a |e <iostr|eam.h>..|
|00000630| 63 6c 61 73 73 20 54 0a | 7b 0a 20 20 20 20 20 70 |class T.|{. p|
|00000640| 75 62 6c 69 63 3a 0a 7d | 3b 0a 0a 0a 63 6c 61 73 |ublic:.}|;...clas|
|00000650| 73 20 41 0a 7b 0a 20 20 | 20 20 20 70 75 62 6c 69 |s A.{. | publi|
|00000660| 63 3a 0a 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |c:. | |
|00000670| 76 69 72 74 75 61 6c 20 | 76 6f 69 64 20 70 72 69 |virtual |void pri|
|00000680| 6e 74 28 69 6e 74 29 20 | 20 7b 20 63 6f 75 74 20 |nt(int) | { cout |
|00000690| 3c 3c 20 22 41 20 69 6e | 74 22 20 3c 3c 20 65 6e |<< "A in|t" << en|
|000006a0| 64 6c 3b 7d 0a 20 20 20 | 20 20 20 20 20 20 20 20 |dl;}. | |
|000006b0| 20 20 76 69 72 74 75 61 | 6c 20 76 6f 69 64 20 70 | virtua|l void p|
|000006c0| 72 69 6e 74 28 63 6f 6e | 73 74 20 54 26 29 20 7b |rint(con|st T&) {|
|000006d0| 20 63 6f 75 74 20 3c 3c | 20 22 41 20 63 68 61 72 | cout <<| "A char|
|000006e0| 22 20 3c 3c 20 65 6e 64 | 6c 3b 7d 0a 0a 7d 3b 0a |" << end|l;}..};.|
|000006f0| 0a 20 63 6c 61 73 73 20 | 42 20 3a 20 70 75 62 6c |. class |B : publ|
|00000700| 69 63 20 41 0a 20 7b 0a | 20 20 20 20 20 70 75 62 |ic A. {.| pub|
|00000710| 6c 69 63 3a 0a 20 20 20 | 20 20 20 20 20 20 20 20 |lic:. | |
|00000720| 20 20 76 69 72 74 75 61 | 6c 20 76 6f 69 64 20 70 | virtua|l void p|
|00000730| 72 69 6e 74 28 69 6e 74 | 29 20 7b 20 63 6f 75 74 |rint(int|) { cout|
|00000740| 20 3c 3c 20 22 42 20 69 | 6e 74 22 20 20 3c 3c 20 | << "B i|nt" << |
|00000750| 65 6e 64 6c 3b 7d 0a 20 | 7d 3b 0a 0a 0a 20 6d 61 |endl;}. |};... ma|
|00000760| 69 6e 28 29 0a 0a 20 7b | 0a 20 20 20 20 20 54 20 |in().. {|. T |
|00000770| 70 3b 0a 20 20 20 20 20 | 41 2a 20 61 20 3d 20 6e |p;. |A* a = n|
|00000780| 65 77 20 41 3b 0a 20 20 | 20 20 20 41 2a 20 62 20 |ew A;. | A* b |
|00000790| 3d 20 6e 65 77 20 42 3b | 0a 20 20 20 20 20 61 2d |= new B;|. a-|
|000007a0| 3e 70 72 69 6e 74 28 70 | 29 3b 20 2f 2f 20 74 68 |>print(p|); // th|
|000007b0| 69 73 20 77 69 6c 6c 20 | 61 6c 77 61 79 73 20 63 |is will |always c|
|000007c0| 61 6c 6c 20 41 3a 3a 70 | 72 69 6e 74 28 63 6f 6e |all A::p|rint(con|
|000007d0| 73 74 20 54 26 29 0a 20 | 20 20 20 20 62 2d 3e 70 |st T&). | b->p|
|000007e0| 72 69 6e 74 28 70 29 3b | 20 2f 2f 20 74 68 69 73 |rint(p);| // this|
|000007f0| 20 77 69 6c 6c 20 63 61 | 6c 6c 20 42 3a 3a 70 72 | will ca|ll B::pr|
|00000800| 69 6e 74 28 63 6f 6e 73 | 74 20 54 26 29 20 69 66 |int(cons|t T&) if|
|00000810| 66 0a 20 20 20 20 20 09 | 09 09 20 20 2f 2f 09 69 |f. .|.. //.i|
|00000820| 74 20 65 78 69 73 74 73 | 20 28 69 74 20 64 6f 65 |t exists| (it doe|
|00000830| 73 6e 27 74 29 20 61 6e | 64 20 41 3a 3a 70 72 69 |sn't) an|d A::pri|
|00000840| 6e 74 28 63 6f 6e 73 74 | 20 54 26 29 20 69 73 20 |nt(const| T&) is |
|00000850| 76 69 72 74 75 61 6c 2c | 0a 20 20 20 20 20 09 09 |virtual,|. ..|
|00000860| 09 20 20 2f 2f 09 6f 74 | 68 65 72 77 69 73 65 20 |. //.ot|herwise |
|00000870| 74 68 69 73 20 77 69 6c | 6c 20 63 61 6c 6c 20 41 |this wil|l call A|
|00000880| 3a 3a 70 72 69 6e 74 28 | 63 6f 6e 73 74 20 54 26 |::print(|const T&|
|00000890| 29 0a 20 20 20 20 20 61 | 2d 3e 70 72 69 6e 74 28 |). a|->print(|
|000008a0| 35 29 3b 20 2f 2f 20 74 | 68 69 73 20 77 69 6c 6c |5); // t|his will|
|000008b0| 20 61 6c 77 61 79 73 20 | 63 61 6c 6c 20 41 3a 3a | always |call A::|
|000008c0| 70 72 69 6e 74 28 69 6e | 74 29 0a 20 20 20 20 20 |print(in|t). |
|000008d0| 62 2d 3e 70 72 69 6e 74 | 28 35 29 3b 20 2f 2f 20 |b->print|(5); // |
|000008e0| 74 68 69 73 20 77 69 6c | 6c 20 63 61 6c 6c 20 42 |this wil|l call B|
|000008f0| 3a 3a 70 72 69 6e 74 28 | 69 6e 74 29 20 69 66 66 |::print(|int) iff|
|00000900| 0a 20 20 20 20 20 09 09 | 09 20 20 2f 2f 09 69 74 |. ..|. //.it|
|00000910| 20 65 78 69 73 74 73 20 | 28 69 74 20 64 6f 65 73 | exists |(it does|
|00000920| 29 20 61 6e 64 20 41 3a | 3a 70 72 69 6e 74 28 69 |) and A:|:print(i|
|00000930| 6e 74 29 20 69 73 20 76 | 69 72 74 75 61 6c 2c 0a |nt) is v|irtual,.|
|00000940| 20 20 20 20 20 09 09 09 | 20 20 2f 2f 09 6f 74 68 | ...| //.oth|
|00000950| 65 72 77 69 73 65 20 74 | 68 69 73 20 77 69 6c 6c |erwise t|his will|
|00000960| 20 63 61 6c 6c 20 41 3a | 3a 70 72 69 6e 74 28 69 | call A:|:print(i|
|00000970| 6e 74 29 0a 20 20 20 20 | 20 09 09 09 20 20 2f 2f |nt). | ... //|
|00000980| 20 66 6f 72 20 74 68 69 | 73 20 63 6f 64 65 20 65 | for thi|s code e|
|00000990| 78 61 6d 70 6c 65 2c 20 | 73 69 6e 63 65 20 74 68 |xample, |since th|
|000009a0| 65 72 65 20 61 72 65 20 | 6e 6f 20 0a 20 20 20 20 |ere are |no . |
|000009b0| 20 09 09 09 20 20 2f 2f | 09 63 6c 61 73 73 65 73 | ... //|.classes|
|000009c0| 20 64 65 72 69 76 65 64 | 20 66 72 6f 6d 20 42 2c | derived| from B,|
|000009d0| 20 6d 61 6b 69 6e 67 20 | 42 3a 3a 70 72 69 6e 74 | making |B::print|
|000009e0| 28 69 6e 74 29 0a 20 20 | 20 20 20 09 09 09 20 20 |(int). | ... |
|000009f0| 2f 2f 09 76 69 72 74 75 | 61 6c 20 64 6f 65 73 20 |//.virtu|al does |
|00000a00| 6e 6f 74 68 69 6e 67 0a | 20 20 20 20 20 72 65 74 |nothing.| ret|
|00000a10| 75 72 6e 20 30 3b 0a 20 | 7d 0a 0a 54 68 65 20 6f |urn 0;. |}..The o|
|00000a20| 75 74 70 75 74 20 66 72 | 6f 6d 20 74 68 65 20 61 |utput fr|om the a|
|00000a30| 62 6f 76 65 20 69 73 3a | 0a 0a 41 20 63 68 61 72 |bove is:|..A char|
|00000a40| 0a 41 20 63 68 61 72 0a | 41 20 69 6e 74 0a 42 20 |.A char.|A int.B |
|00000a50| 69 6e 74 0a 0a 0a 0a 4b | 65 76 69 6e 20 49 6e 67 |int....K|evin Ing|
|00000a60| 61 6c 6c 73 2c 20 28 32 | 30 36 29 37 37 33 2d 39 |alls, (2|06)773-9|
|00000a70| 34 30 34 2c 20 69 6e 67 | 6b 6c 39 30 30 40 63 63 |404, ing|kl900@cc|
|00000a80| 6d 61 69 6c 2e 63 61 2e | 62 6f 65 69 6e 67 2e 63 |mail.ca.|boeing.c|
|00000a90| 6f 6d 0a 0a 0a | |om... | |
+--------+-------------------------+-------------------------+--------+--------+